package edu.cuit.avatar.collection;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/10 8:55
 */
public class Circle extends Geometric implements Cloneable, Comparable<Circle> {
    public static final float PI = 3.14f;
    private float radius;

    public Circle(float radius) {
        this.radius = radius;
    }
    public Circle(float radius, String color, boolean filled) {
        super(color, filled);
        this.radius = radius;
    }

    public float getRadius() {
        return radius;
    }

    public void setRadius(float radius) {
        this.radius = radius;
    }

    /**
     * 计算面积
     * @return 面积
     */
    @Override
    public float getArea(){
        return PI * radius * radius;
    }

    /**
     * 计算周长
     * @return 周长
     */
    @Override
    public float getPerimeter(){
        return 2 * PI * radius;
    }

    @Override
    public Circle clone() throws CloneNotSupportedException {
        return (Circle)super.clone();
    }

    @Override
    public int compareTo(Circle o) {
        return Float.compare(radius, o.radius);
    }
}
